package resultsDatabase;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;

import recordsDatabase.Person;



public class Result implements Comparable<Result> , Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3901006460193358641L;
	private ArrayList<Person> personsList= new ArrayList<Person>();
	private Set<Field> resultFields = new LinkedHashSet<Field>();
	private String threadName;

	
	public Result(Set<Field> fields, ArrayList<Person> list,String name){
		resultFields=fields;
		personsList=list;
		threadName=name;
		
	}
	
	public String resultFieldsToString(){
		StringBuilder line = new StringBuilder();
		line.append("Fields: ");
		for (Field f:resultFields){
			line.append(f.getField());
			line.append(" , ");
		}
		line.append(" .");
		line.append(threadName);
		return line.toString();
	}
	
	public ArrayList<Person> getPersonsList(){return personsList;}
	public Set<Field> getResultType(){return resultFields;}
	public String getThreadName(){return threadName;}
	public int compareTo(Result o) {
		return o.personsList.size() - this.personsList.size() ;
	}
	
}
